﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace BAL
{
   public class Topics
    {
       public static string con = BAL.conn.connectionString;

       public static int CreateTopic(int Iduser, int IDVocation, string title, string desc)
       {
           SqlParameter[] arrParam = new SqlParameter[4];
           arrParam[0] = new SqlParameter("@iduser", SqlDbType.Int);
           arrParam[0].Value=Iduser;
           arrParam[1] = new SqlParameter("@IDVocation", SqlDbType.Int);
           arrParam[1].Value = IDVocation;
           arrParam[2] = new SqlParameter("@title", SqlDbType.VarChar);
           arrParam[2].Value = title;
           arrParam[3] = new SqlParameter("@desc", SqlDbType.VarChar);
           arrParam[3].Value = desc;

           int IDTopic=Convert.ToInt32(VocationSpace.DAL.SqlHelper.ExecuteNonQuery(con,CommandType.StoredProcedure,"VS_CreateTopic",arrParam));
           return IDTopic;
       }
       public static void UpdateTopicViews(int Idtopic)
       {
           SqlParameter[] arrParam = new SqlParameter[1];
           arrParam[0] = new SqlParameter("@idtopic", SqlDbType.Int);
           arrParam[0].Value = Idtopic;

           VocationSpace.DAL.SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "VS_UpdateTopicView", arrParam);
       }
       public static void UpdateTopicLikes(int Idtopic)
       {
           SqlParameter[] arrParam = new SqlParameter[1];
           arrParam[0] = new SqlParameter("@idtopic", SqlDbType.Int);
           arrParam[0].Value = Idtopic;

           VocationSpace.DAL.SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "VS_UpdateTopicLikes", arrParam);
       }
       public static void UpdateTopicReply(int Idtopic)
       {
           SqlParameter[] arrParam = new SqlParameter[1];
           arrParam[0] = new SqlParameter("@idtopic", SqlDbType.Int);
           arrParam[0].Value = Idtopic;

           VocationSpace.DAL.SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "VS_UpdateTopicReplyCount", arrParam);
       }

       public static DataSet GetTopicByUser(int IDUser)
       {
           SqlParameter[] arrParam = new SqlParameter[1];
           arrParam[0] = new SqlParameter("@IDUser", SqlDbType.Int);
           arrParam[0].Value = IDUser;

          DataSet ds = VocationSpace.DAL.SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "VS_GetTopicByUser", arrParam);
          return ds;
       }

       public static DataSet GetTopicOfMentisByUser(int IDUser)
       {
           SqlParameter[] arrParam = new SqlParameter[1];
           arrParam[0] = new SqlParameter("@IDUser", SqlDbType.Int);
           arrParam[0].Value = IDUser;

           DataSet ds = VocationSpace.DAL.SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "VS_GetTopicOfMentisByUser", arrParam);
           return ds;
       }

       public static DataSet GetTopicOfMentorByUser(int IDUser)
       {
           SqlParameter[] arrParam = new SqlParameter[1];
           arrParam[0] = new SqlParameter("@IDUser", SqlDbType.Int);
           arrParam[0].Value = IDUser;

           DataSet ds = VocationSpace.DAL.SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "VS_GetTopicOfMentorByUser", arrParam);
           return ds;
       }  

    }
}
